//
//  CollectionViewCell1.m
//  BAOASystem
//
//  Created by michael on 2018/1/25.
//  Copyright © 2018年 czd. All rights reserved.
//

#import "CollectionViewCell1.h"
#import "shangpinlistViewController.h"
@implementation CollectionViewCell1

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
//    _button1.hidden = YES;
//    _button2.hidden = YES;
//    _button3.hidden = YES;
//    _button4.hidden = YES;
}
- (void)layoutSubviews{
[super layoutSubviews];
NSMutableArray *array = [NSMutableArray array];
for (NSDictionary *dic in _array) {
    [array addObject:dic[@"ctgName"]];
}
if (array.count==1) {
    _button1.hidden = NO;
    [_button1 setTitle:array[0] forState:UIControlStateNormal];
       _button2.hidden = YES;
    _button3.hidden = YES;
    _button4.hidden = YES;

}
else if (array.count==2) {
    _button1.hidden = NO;
    [_button1 setTitle:array[0] forState:UIControlStateNormal];
     _button2.hidden = NO;
    [_button2 setTitle:array[1] forState:UIControlStateNormal];
     _button3.hidden = YES;
    _button4.hidden = YES;
}
 else if (array.count==3) {
    _button1.hidden = NO;
    [_button1 setTitle:array[0] forState:UIControlStateNormal];
     _button2.hidden = NO;
    [_button2 setTitle:array[1] forState:UIControlStateNormal];
     _button3.hidden = NO;
    [_button3 setTitle:array[2] forState:UIControlStateNormal];
        _button4.hidden = YES;

}else if (array.count>=4){
  _button1.hidden = NO;
    [_button1 setTitle:array[0] forState:UIControlStateNormal];
     _button2.hidden = NO;
    [_button2 setTitle:array[1] forState:UIControlStateNormal];
     _button3.hidden = NO;
    [_button3 setTitle:array[2] forState:UIControlStateNormal];
       _button4.hidden = NO;
    [_button4 setTitle:array[3] forState:UIControlStateNormal];

}

  
}
- (IBAction)action1:(id)sender {
shangpinlistViewController *vc = [[shangpinlistViewController alloc]init];
NSDictionary *dic = _array[0];
vc.ctgid = dic[@"id"];
vc.hidesBottomBarWhenPushed  = YES;
[self.ViewController.navigationController pushViewController:vc animated:YES];

}

- (IBAction)action2:(id)sender {
shangpinlistViewController *vc = [[shangpinlistViewController alloc]init];
NSDictionary *dic = _array[1];
vc.ctgid = dic[@"id"];
vc.hidesBottomBarWhenPushed  = YES;
[self.ViewController.navigationController pushViewController:vc animated:YES];

}

- (IBAction)action3:(id)sender {
shangpinlistViewController *vc = [[shangpinlistViewController alloc]init];
NSDictionary *dic = _array[2];
vc.ctgid = dic[@"id"];
vc.hidesBottomBarWhenPushed  = YES;
[self.ViewController.navigationController pushViewController:vc animated:YES];

}

- (IBAction)action4:(id)sender {
shangpinlistViewController *vc = [[shangpinlistViewController alloc]init];
NSDictionary *dic = _array[3];
vc.ctgid = dic[@"id"];
vc.hidesBottomBarWhenPushed  = YES;
[self.ViewController.navigationController pushViewController:vc animated:YES];

}
@end
